package com.jinhua.huaoj.judge;

import com.jinhua.huaoj.judge.strategy.DefaultJudgeStrategy;
import com.jinhua.huaoj.judge.strategy.JavajudgeStrategy;
import com.jinhua.huaoj.judge.strategy.JudgeStrategy;
import com.jinhua.huaoj.model.entity.JudgeContext;
import com.jinhua.huaoj.judge.model.JudgeInfo;
import com.jinhua.huaoj.model.enums.QuestionSubmitLanguageEnum;
import org.springframework.stereotype.Component;

/**
 * 判题管理（简化调用）
 * 根据语言选择不同的判题策略
 */
@Component
public class JudgeManager {
    public JudgeInfo doJudge(JudgeContext judgeContext) {
        //拿到用户提交时使用的语言，选择不同的策略进行执行
        String language = judgeContext.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if (QuestionSubmitLanguageEnum.JAVA.getValue().equals(language)){
            judgeStrategy = new  JavajudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);

    }
}
